package com.bfl.sa.personal.message.mapper;

import com.bfl.sa.common.mapper.BaseMapper;
import com.bfl.sa.personal.message.entity.Message;
import com.bfl.sa.personal.message.entity.MessageContent;
import com.bfl.sa.personal.message.entity.MessageState;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


public interface MessageMapper extends BaseMapper<Message, Long> {

    int changeSenderState(
            @Param("senderId") Long senderId,
            @Param("oldState") MessageState oldState,
            @Param("newState") MessageState newState,
            @Param("changeDate") Date changeDate);

    int changeReceiverState(
            @Param("receiverId") Long receiverId,
            @Param("oldState") MessageState oldState,
            @Param("newState") MessageState newState,
            @Param("changeDate") Date changeDate);


    int changeSenderStates(
            @Param("oldStates") ArrayList<MessageState> states,
            @Param("newState") MessageState newStates,
            @Param("changeDate") Date changeDate,
            @Param("expireDate") Date expireDate);

    int changeReceiverStates(
            @Param("oldStates") ArrayList<MessageState> oldStates,
            @Param("newState") MessageState newState,
            @Param("changeDate") Date changeDate,
            @Param("expireDate") Date expireDate);

    int clearDeletedMessage(@Param("state") MessageState deletedState);

    Long countUnread(@Param("userId") Long userId, @Param("receiverState") MessageState receiverState);

    void markRead(@Param("userId") Long userId, @Param("ids") List<Long> ids);

    void insertContent(@Param("messageId") Long messageId, @Param("content") MessageContent content);
}
